package com.wyzz.hr.util.tags;

import com.opensymphony.xwork2.util.ValueStack;
import com.wyzz.hr.bo.ILocationBO;
import com.wyzz.hr.pojo.Location;
import com.wyzz.hr.spring.SpringBeanFactory;

import java.util.Iterator;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts2.components.UIBean;

public class EmpselectorComp extends UIBean {

	public EmpselectorComp(ValueStack stack, HttpServletRequest request,
			HttpServletResponse response) {
		super(stack, request, response);
	}

	protected String getDefaultTemplate() {
		return "empselector";
	}

	protected void evaluateExtraParams() {
		super.evaluateExtraParams();
		if (this.isShowDisable != null)
			addParameter("isShowDisable", findString(this.isShowDisable));
		else {
			addParameter("isShowDisable", "hide");
		}
		if (this.isShowPb != null)
			addParameter("isShowPb", findString(this.isShowPb));
		else {
			addParameter("isShowPb", "show");
		}
		if (this.hiddenFieldName != null) {
			addParameter("hiddenFieldName", findString(this.hiddenFieldName));
			addParameter("hiddenFieldNameValue",
					findValue(this.hiddenFieldName));
		}
		if (this.condition != null) {
			addParameter("condition", findString(this.condition));
			addParameter("conditionValue", findValue(this.condition));
		}
		ILocationBO localbo = (ILocationBO) SpringBeanFactory
				.getBean("locationBO");
		List<Location> locationList = localbo.FindEnabledLocation();
		this.localSelect = "<select name='location' id='empSelector_location'>";
		this.localSelect += "<option value=''>\u8BF7\u9009\u62E9</option>";
		if ((locationList != null) && (!locationList.isEmpty())) {
			for (Location loc : locationList) {
				this.localSelect = (this.localSelect + "<option value='"
						+ loc.getId() + "'>" + loc.getLocationName() + "</option>");
			}
		}
		this.localSelect += "</select>";
		addParameter("localSelect", this.localSelect);

	}

	public String getHiddenFieldName() {
		return hiddenFieldName;
	}

	public void setHiddenFieldName(String hiddenFieldName) {
		this.hiddenFieldName = hiddenFieldName;
	}

	public String getIsShowDisable() {
		return isShowDisable;
	}

	public void setIsShowDisable(String isShowDisable) {
		this.isShowDisable = isShowDisable;
	}

	public String getIsShowPb() {
		return isShowPb;
	}

	public void setIsShowPb(String isShowPb) {
		this.isShowPb = isShowPb;
	}

	public String getCondition() {
		return condition;
	}

	public void setCondition(String condition) {
		this.condition = condition;
	}

	public String getLocalSelect() {
		return localSelect;
	}

	public void setLocalSelect(String localSelect) {
		this.localSelect = localSelect;
	}

	public final String TEMPLATE = "empselector";
	private String hiddenFieldName;
	private String isShowDisable;
	private String isShowPb;
	private String condition;
	private String localSelect;
}
